package com.xxyy.mylive.tools;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Point;
import android.os.PowerManager;
import android.view.WindowManager;
import android.widget.Toast;

/**
 * Ui相关工具类
 * Created by ado on 21:34 2016/10/19.
 */
public class UiTool {

    public static void showToast(Context context, String showContent) {
        Toast.makeText(context, showContent, Toast.LENGTH_SHORT).show();
    }

    /**
     * 屏幕常亮
     *
     * @param context
     */
    public static void keepScreenWake(Context context) {
        PowerManager powerManager = (PowerManager) context.getSystemService(context.POWER_SERVICE);
        PowerManager.WakeLock wakeLock = powerManager.newWakeLock(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, "record");
        wakeLock.acquire();
    }

    public static Point getScreenPoint(Context context) {
        Point point = new Point();
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        windowManager.getDefaultDisplay().getSize(point);
        return point;
    }
}
